package com.ktgj.customer.controller;

import java.text.SimpleDateFormat;
import java.util.*;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ktgj.common.core.constant.FileConstants;
import com.ktgj.common.core.utils.StringUtils;
import com.ktgj.common.log.annotation.SignatureValidation;
import com.ktgj.common.redis.service.RedisService;
import com.ktgj.customer.domain.*;
import com.ktgj.customer.domain.vo.*;
import com.ktgj.customer.service.ILoginService;
import com.ktgj.customer.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.customer.service.ICustomerService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;

/**
 * 会员基本信息Controller
 *
 * @author ruoyi
 * @date 2021-07-30selectCustomerReturnCardByPhone
 */
@ControllerAdvice
@RestController
@RequestMapping("/customer")
public class CustomerController extends BaseController {
    @Autowired
    private ICustomerService customerService;

    @Autowired
    private ILoginService loginService;

    @Autowired
    private RedisService redisService;

    /**
     * 获取当前用户的ID
     *
     * @param request
     * @return
     */

    public Long customerId(HttpServletRequest request) {
        Long customerId = loginService.getLoginCustomer(request).getCustomerId();
        return customerId;
    }

    /**
     * 查询会员基本信息列表
     */
    //@PreAuthorize(hasPermi = "customer:customer:list")
    @GetMapping("/list")
    public TableDataInfo list(Customer customer) {
        startPage();
        List<Customer> list = customerService.selectCustomerList(customer);
        return getDataTable(list);
    }

    @PostMapping("/customerList")
    public List<Customer> customerList(@RequestBody Customer customer) {
        List<Customer> list = customerService.selectCustomerList(customer);
        return list;
    }

    /**
     * 查询退卡
     * @param map
     * @return
     */
    @PostMapping("/getCustomerReturnCardByPhone")
    public TableDataInfo getCustomerReturnCardByPhone(@RequestBody Map<String, String> map)
    {
        startPage();
        String phone = map.get("phone");
        List<CustomerReturnCard> list = customerService.selectCustomerReturnCardByPhone(phone);
        return getDataTable(list);
    }

    /**
     * 查询退卡
     * @param map
     * @return
     */
    @PostMapping("/customerReturnCardByPhone")
    public TableDataInfo customerReturnCardByPhone(@RequestBody Map<String, String> map)
    {
        startPage();
        String phone = map.get("phone");
        List<CustomerReturnCard> list = customerService.tmpSelectCustomerReturnCardByPhone(phone);
        return getDataTable(list);
    }
    /**
     * 查询退卡审核
     * @param map
     * @return
     */
    @PostMapping("/getCustomerReturnCardByCardCode")
   public AjaxResult getCustomerReturnCardByCardCode(@RequestBody Map<String, String> map){
        String cardCode=map.get("cardCode");
        if (cardCode!= null && !cardCode.isEmpty()){
            return AjaxResult.success(customerService.selectCustomerReturnCardBycardCode(cardCode));
        }
        return AjaxResult.error("卡号为空");
    }
   /**
    * 退卡待审核列表
    * @param customerReturnCard
   * @return
   */
   @PostMapping("/selectCustomerReturnCardByorderDate")
   public TableDataInfo selectCustomerReturnCardByorderDate(@RequestBody  CustomerReturnCard customerReturnCard )
   {
       startPage();
       List<CustomerReturnCard> list;
       try {
           list = customerService.selectCustomerReturnCardByorderDate(customerReturnCard);
       } catch (Exception e){
           return null;
       }
       return getDataTable(list);
   }
    /**
     * 查询一个会员有几张卡
     * @param map
     * @return
     */
       @PostMapping("/getCustomerCardByCustomerId")
       public AjaxResult getCustomerCardByCustomerId(@RequestBody Map<String, Object> map){
        Long customerId=new Long(map.get("customerId").toString());
        List<CustomerReturnCard> list=customerService.getCustomerCardByCustomerId(customerId);
        return AjaxResult.success(list);
       }

    /**
     * 查询会员信息
     * @param map
     * @return
     */
        @PostMapping("/selectCustomerByPhone")
        public  AjaxResult selectCustomerByPhone(@RequestBody Map<String, String> map){
         String phone=map.get("phone");
         String idCode=map.get("idCode");
         Customer customer=customerService.selectCustomerByPhone(phone,idCode);
         if(customer != null){
            return AjaxResult.success(customer);
         }else {
             return AjaxResult.error("查询会员为空");
         }
        }
    /**
     * 导出会员基本信息列表
     */
    //@PreAuthorize(hasPermi = "customer:customer:export")
    @Log(title = "会员基本信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Customer customer) throws IOException {
        List<Customer> list = customerService.selectCustomerList(customer);
        ExcelUtil<Customer> util = new ExcelUtil<Customer>(Customer.class);
        util.exportExcel(response, list, "会员基本信息数据");
    }

    /**
     * 获取会员基本信息详细信息
     */
    //@PreAuthorize(hasPermi = "customer:customer:query")
    @GetMapping(value = "/{customerId}")
    public AjaxResult getCustomerInfo(@PathVariable("customerId") Long customerId) {
        return AjaxResult.success(customerService.selectCustomerById(customerId));
    }

    /**
     * 根据会员id查询详细信息
     * @param customerId
     * @return
     */
    @PostMapping("/getCustomerId")
    public AjaxResult getCustomerId(@RequestParam("customerId") Long customerId) {
        return AjaxResult.success(customerService.selectCustomerById(customerId));
    }

    /**
     * 根据会员ID获取会员权益中所有券
     */
    //@GetMapping(value = "/getCustomerCoupon/{customerId}")
    public AjaxResult getCustomerCoupon(@PathVariable("customerId") Long customerId) {
        return AjaxResult.success(customerService.getCustomerRightCoupon(customerId));
    }

    /**
     * 新增会员基本信息
     */
    //@PreAuthorize(hasPermi = "customer:customer:add")
    @Log(title = "会员基本信息", businessType = BusinessType.INSERT)
    @PostMapping("add")
    public AjaxResult add(@RequestBody Customer customer) {
        return toAjax(customerService.insertCustomer(customer));
    }

    /**
     * 修改会员基本信息
     */
    //@PreAuthorize(hasPermi = "customer:customer:edit")
    @Log(title = "会员基本信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(HttpServletRequest request, @RequestBody Customer customer, MultipartFile file) {
        String token = request.getHeader("token");
        return AjaxResult.success(customerService.updateCustomer(customer, token));
    }

    /**
     * 修改会员基本信息
     */
    @PostMapping("/update")
    public AjaxResult update(@RequestBody Customer customer) {
        return toAjax(customerService.update(customer));
    }

    /**
     * 删除会员基本信息
     */
    //@PreAuthorize(hasPermi = "customer:customer:remove")
    @Log(title = "会员基本信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{customerIds}")
    public AjaxResult remove(@PathVariable Long[] customerIds) {
        return toAjax(customerService.deleteCustomerByIds(customerIds));
    }

    /**
     * 会员基本信息与常用地址对象关联查询（一对多）
     *
     * @param customerId
     * @return
     */
    @PostMapping("/selectCustomerAndCommonAddressesList")
    public AjaxResult selectCustomerAndCommonAddressesList(Long customerId) {
        return AjaxResult.success(customerService.selectCustomerAndCommonAddressesList(customerId));
    }

    /**
     * 会员基本信息与常用报销凭证信息对象关联查询（一对多）
     *
     * @param customerId
     * @return
     */
    @PostMapping("/selectCustomerAndCommonReimbursementsList")
    public AjaxResult selectCustomerAndCommonReimbursementsList(Long customerId) {
        return AjaxResult.success(customerService.selectCustomerAndCommonReimbursementsList(customerId));
    }

    /**
     * 会员基本信息与常用旅客信息对象关联查询（一对多）
     *
     * @param customerId
     * @return
     */
    @PostMapping("/selectCustomerAndCommonTravelersList")
    public AjaxResult selectCustomerAndCommonTravelersList(Long customerId) {
        return AjaxResult.success(customerService.selectCustomerAndCommonTravelersList(customerId));
    }

    /**
     * 会员基本信息与银行卡信息对象关联查询（一对多）
     *
     * @param customerId
     * @return
     */
    @PostMapping("/selectCustomerAndBankCardList")
    public AjaxResult selectCustomerAndBankCardList(Long customerId) {
        return AjaxResult.success(customerService.selectCustomerAndBankCardList(customerId));
    }

    /**
     * 我的-编辑个人信息
     *
     * @param customer
     * @return
     */
    //@SignatureValidation
    @PostMapping("/editPersonalInformation")
    public AjaxResult editPersonalInformation(HttpServletRequest request, @RequestBody Customer customer) {
        String token = request.getHeader("token");
        try {
            customer.setCustomerId(customerId(request));
        } catch (Exception e) {
            return AjaxResult.error(e.getMessage());
        }
        Customer updateCustomer = customerService.updateCustomer(customer, token);
        if (updateCustomer != null) {
            return AjaxResult.success(updateCustomer);
        } else {
            return AjaxResult.error("修改失败");
        }
    }

    /**
     * 我的-编辑个人信息
     *
     * @param customer
     * @return
     */
//    @SignatureValidation
    @PostMapping("/editCustomer")
    public AjaxResult editCustomer(@RequestBody Customer customer) {
        if (customer != null){
            int update = customerService.update(customer);
            if (update > 0) {
                return AjaxResult.success("修改成功");
            } else {
                return AjaxResult.error("修改失败");
            }
        }
        else {
            return AjaxResult.error("缺少必要参数");
        }
    }

    /**
     * 查询当前会员信息
     */
    //@SignatureValidation
    @PostMapping("/selectMemberInformation")
    public AjaxResult selectMemberInformation(HttpServletRequest request) {
        Long customerId;
        try {
            customerId = customerId(request);
        } catch (Exception e) {
            return AjaxResult.error(e.getMessage());
        }
        if (customerId != null) {
            return AjaxResult.success(customerService.selectMemberInformation(customerId));
        } else {
            return AjaxResult.error("未查询到该会员信息");
        }
    }

    /**
     * 我的-添加证件
     *
     * @param
     * @return
     */
    //@SignatureValidation
    @PostMapping("/insertCertificate")
    public AjaxResult insertCertificate(@RequestBody Map<String, Object> map, HttpServletRequest request) {
        Long customerId;
        try {
            customerId = customerId(request);
        } catch (Exception e) {
            return AjaxResult.error(e.getMessage());
        }
        String idType = map.get("idType").toString();
        String custCertificateNo = map.get("custCertificateNo").toString();
        String invalidDate = map.get("invalidDate").toString();

        return AjaxResult.success(customerService.updateCustomerByCertificate(customerId, idType, custCertificateNo, invalidDate));
    }

    /**
     * 我的-积分
     *
     * @return
     */
    //@SignatureValidation
    @PostMapping("/selectPointRecordByCustomerId")
    public AjaxResult selectPointRecordByCustomerId(HttpServletRequest request) {
        Long customerId;
        try {
            customerId = customerId(request);
        } catch (Exception e) {
            return AjaxResult.error(e.getMessage());
        }
        return AjaxResult.success(customerService.selectPointRecordByCustomerId(customerId));
    }

    /**
     * 我的-信息
     */
    //@SignatureValidation
//    @Log(title = "我的信息", businessType = BusinessType.OTHER, isSaveRequestData = true)
    @PostMapping("/selectPersonalInformation")
    public AjaxResult selectPersonalInformation(HttpServletRequest request) {
        Long customerId;
        try {
            customerId = customerId(request);
        } catch (Exception e) {
            return AjaxResult.error(e.getMessage());
        }

        CurrentMemberVo currentMemberVo = customerService.selectCustomerByCustomerId(customerId);
        if (currentMemberVo != null) {
            return AjaxResult.success(currentMemberVo);
        } else {
            return AjaxResult.error("系统错误，查询失败");
        }
    }

    /**
     * 我的-积分明细
     */
    //@SignatureValidation
    @PostMapping("/selectIntegralDetail")
    public AjaxResult selectIntegralDetail(HttpServletRequest request, @RequestBody Map<String, Object> map) {
        Long customerId;
        try {
            customerId = customerId(request);
        } catch (Exception e) {
            return AjaxResult.error(e.getMessage());
        }
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");

        Date date;
        try {
            date = sdf.parse(map.get("date").toString());
        } catch (Exception e) {
            return AjaxResult.error("未输入查询时间");
        }

        PointRecordIntegraVo pointRecordIntegraVo;
        try {
            pointRecordIntegraVo = customerService.selectCustomerDetail(customerId, date);
        } catch (Exception e) {
            return AjaxResult.error("系统错误，查询失败");
        }
        return AjaxResult.success(pointRecordIntegraVo);
    }


    /**
     * 修改密码
     */
    //@SignatureValidation
    @PostMapping("/changePassword")
    public AjaxResult changePassword(HttpServletRequest request, @RequestBody Map<String, Object> map) {
        Long customerId;
        try {
            customerId = customerId(request);
        } catch (Exception e) {
            return AjaxResult.error(e.getMessage());
        }
        String NewCustLoginPswmd5One = map.get("NewCustLoginPswmd5One").toString();
        String NewCustLoginPswmd5Two = map.get("NewCustLoginPswmd5Two").toString();
        String CustLoginPswmd5 = map.get("CustLoginPswmd5").toString();
        try {
            return AjaxResult.success(customerService.updateCustomerByCustLoginPswmd5(customerId, NewCustLoginPswmd5One,
                    NewCustLoginPswmd5Two, CustLoginPswmd5));
        } catch (Exception e) {
            return AjaxResult.error(e.getMessage());
        }
    }

    /**
     * 积分到期提示列表
     */
    //@SignatureValidation
    @PostMapping("willExpireSoonIntegral")
    public AjaxResult willExpireSoonIntegral(HttpServletRequest request) {
        Long customerId;
        try {
            customerId = customerId(request);
        } catch (Exception e) {
            return AjaxResult.error(e.getMessage());
        }
        List<WillExpireSoonVo> willExpireSoonVoList = customerService.willExpireSoonIntegral(customerId);
        if (willExpireSoonVoList.size() > 0) {
            return AjaxResult.success(willExpireSoonVoList);
        } else {
            return AjaxResult.error("当前用户没有即将过期积分");
        }
    }

    /**
     * 根据会员两个手机号查找会员信息
     *
     * @param moblieId
     * @return
     */
    @PostMapping("getCustomerByMobile")
    public Customer getCustomerByMobile(String moblieId) {
        Customer customer = customerService.getCustomerByMobileId(moblieId);
        if (customer != null) {
            return customer;
        }
        return null;
    }

    /**
     * 根据token查询用户首页显示的会员卡登记
     */
    @PostMapping("getCustomerCardDisplay")
    public AjaxResult getCustomerCardDisplay(HttpServletRequest request) {
        return AjaxResult.success("操作成功", customerService.getCustomerCardDisplay(loginService.getLoginCustomer(request).getCustomerId()));
    }

    /**
     * 根据token查询用户在下单页面时显示的会员卡距离到期还有多少天
     */
    @PostMapping("getCustomerCardExpireDays")
    public AjaxResult getCustomerCardExpireDays(HttpServletRequest request) {
        return AjaxResult.success("操作成功", customerService.getCustomerCardExpireDays(loginService.getLoginCustomer(request).getCustomerId()));
    }

    /**
     * 登机牌会员价格汇总
     * */
    @PostMapping("/customerPriceSummary")
    public AjaxResult customerPriceSummary(HttpServletRequest request){
        Long customerId = loginService.getLoginCustomer(request).getCustomerId();
        List<SummaryVo> summaryVoList = customerService.customerPriceSummary(customerId);

        if (summaryVoList != null && summaryVoList.size() > 0){
            return AjaxResult.success(summaryVoList);
        }
        else {
            return AjaxResult.error(null);
        }
    }

    /**
     * 查询会员信息（CRM）
     * @param map
     * @return
     */
    @PostMapping("/queryCustomer")
    public AjaxResult queryCustomer(@RequestBody Map<String, Object> map) {
        String phone = null;
        String idCode = null;
        String cardNum = null;
        if (map.get("phone") != null && !map.get("phone").equals("")) {
            phone = String.valueOf(map.get("phone"));
        }
        if (map.get("idCode") != null && !map.get("idCode").equals("")) {
            idCode = String.valueOf(map.get("idCode"));
        }
        if (map.get("cardNum") != null && !map.get("cardNum").equals("")){
            cardNum = String.valueOf(map.get("cardNum"));
        }

        CustomerCRM customer;
        try {
            customer = customerService.queryCustomer(phone, idCode, cardNum);
        } catch (Exception e){
            return AjaxResult.error("会员信息不正确或不存在此会员！");
        }
        if (customer != null) {
            return AjaxResult.success(customer);
        } else {
            return AjaxResult.error("没有查询到会员信息！");
        }
    }

    /**
     * 会员识别
     * @param customerIdentify
     * @return
     */
    @PostMapping("/selectCustomerIdentify")
    public  TableDataInfo selectCustomerIdentify(@RequestBody CustomerIdentify customerIdentify){
            startPage();
            List<CustomerIdentify> list =customerService.selectCustomerIdentify(customerIdentify);
            return getDataTable(list) ;
    }

    /**
     * 会员姓名查id
     * */
    @PostMapping("/customerByCustomerName")
    public Long customerByCustomerName(@RequestBody VipCustomerVo vipCustomerVo) {
        if (vipCustomerVo != null){
            Long aLong = customerService.customerByCustomerName(vipCustomerVo);
            if (aLong != null && aLong != 0){
                return aLong;
            }
            else {
                return 0l;
            }
        }
        else {
            return 0l;
        }
    }


    /**
     * crm会员信息查询
     */
    @PostMapping("queryCRMCustomerData")
    public AjaxResult queryCRMCustomerData(@RequestBody Map<String, Object> map) {
        Long customerId = map.get("customerId") != null && !map.get("customerId").equals("0") && !map.get("customerId").equals("") ? new Long(map.get("customerId").toString()) : null;
        String phone = map.get("phone") != null && !map.get("phone").equals("") ? map.get("phone").toString() : null;
        String certificateNo = map.get("certificateNo") != null && !map.get("certificateNo").equals("") ? map.get("certificateNo").toString() : null;
        String cardCode = map.get("cardCode") != null && !map.get("cardCode").equals("") ? map.get("cardCode").toString() : null;
        String customerName = map.get("customerName") != null && !map.get("customerName").equals("") ? map.get("customerName").toString() : null;
        if (customerId == null && phone == null && certificateNo == null && cardCode == null && customerName == null)
            return AjaxResult.error("至少传入一个参数");
//        customerId = customerId == null ? 0 : customerId;
        phone = phone == null ? "" : phone;
        certificateNo = certificateNo == null ? "" : certificateNo;
        cardCode = cardCode == null ? "" : cardCode;
        customerName = customerName == null ? "" : customerName;
        return AjaxResult.success(customerService.queryCRMCustomerData(customerId, phone, certificateNo, cardCode, customerName));
    }

    /**
     * 根据卡类型分组来查询会员信息
     * @return
     */
    @PostMapping("/getCustomerCardGroup")
    public AjaxResult getCustomerCardGroupList()
    {
        return AjaxResult.success(customerService.getCustomerCardGroupList());
    }
    /**
     * 生成会员二维码
     */
    @PostMapping("/generateCustomerQrCode")
    public AjaxResult generateCustomerQrCode(@RequestBody Map<String,Object>map){
         return AjaxResult.success("成功",customerService.generateCustomerQrCode(map.get("customerId").toString()));
    }
    /**
     * 检索三个月内未读的会员消息
     */
    @PostMapping("/selectCustomerMessage")
    public AjaxResult selectCustomerMessage(HttpServletRequest request,@RequestBody Map<String,String>map){
        Long customerId;
        if(map.get("customerId") != null && !map.get("customerId").equals("")){
            customerId=new Long(map.get("customerId").toString());
        }
        else {
            String token = request.getHeader("token");
            customerId = loginService.getLoginCustomerByToken(token).getCustomerId();
        }
        CustomerMessage customerMessage=new CustomerMessage();
        customerMessage.setCustomerId(customerId);
        return AjaxResult.success("成功",customerService.selectCustomerMessage(customerMessage));
    }

    /**
     * 新增会员消息
     */
    @PostMapping("/addCustomerMessage")
    public AjaxResult addCustomerMessage(@RequestBody Map<String,String>map){
        Long customerId = null;
        if(map.get("customerId") != null && !map.get("customerId").equals("")){
            customerId=new Long(map.get("customerId"));
        }
        CustomerMessage customerMessage=new CustomerMessage();
        customerMessage.setMessageContent(map.get("messageContent"));
        customerMessage.setBusinessType(map.get("businessType"));
        customerMessage.setBusinessOrderId(new Long(map.get("businessOrderId")));
        customerMessage.setCustomerId(customerId);
        int i=customerService.addCustomerMessage(customerMessage);
        if(i>0){
            return  AjaxResult.success("成功",i);
        }
        return AjaxResult.success("添加失败",0);
    }
    /**
     * 修改会员消息状态
     */
    @PostMapping("/updateCustomerMessage")
    public AjaxResult updateCustomerMessage(HttpServletRequest request, @RequestBody Map<String,String> map){
        Long customerId = loginService.getLoginCustomer(request).getCustomerId();
        CustomerMessage customerMessage=new CustomerMessage();
        customerMessage.setCustomerId(customerId);
        Long messageId = Long.parseLong(map.get("messageId"));
        customerMessage.setCustomerMessageId(messageId);
        int i=customerService.updateCustomerMessage(customerMessage);
        if(i>0){
            return  AjaxResult.success("成功",i);
        }
        return  AjaxResult.success("修改失败",0);
    }

    /**
     * 工单获取会员部分信息
     * */
    @PostMapping("/customerId")
    public AjaxResult customerId(@RequestBody CustomerIdVo customerIdVo) {
        if (customerIdVo != null){
            try {
                customerIdVo = customerService.customerId(customerIdVo);

            } catch (Exception e){
                return AjaxResult.error(e.getMessage());
            }
            return AjaxResult.success(customerIdVo);
        }
        else {
            return AjaxResult.error("缺少必要参数");
        }
    }

    /**
     * 根据会员信息查id
     * */
    @PostMapping("/customerIdApi")
    public CustomerIdVo customerIdApi(@RequestBody CustomerIdVo customerIdVo) {
        if (customerIdVo != null){
            try {
                customerIdVo = customerService.customerId(customerIdVo);

            } catch (Exception e){
                e.printStackTrace();
                return null;
            }
            return customerIdVo;
        }
        else {
            return null;
        }
    }

    /**
     * 根据会员信息查id
     * */
    @PostMapping("/customerPhone")
    public AjaxResult customerPhone(@RequestBody Map<String, Object> map) {
        Long id = Long.valueOf(map.get("id").toString());
        CustomerIdVo customerIdVo = new CustomerIdVo();
        customerIdVo.setCustomerId(id);
        try {
            customerIdVo = customerService.customerId(customerIdVo);

        } catch (Exception e){
            return AjaxResult.error(e.getMessage());
        }
        return AjaxResult.success(customerIdVo);
    }

    /**
     * 检索三个月所有的会员消息
     * */
    @PostMapping("/selectAllCustomerMessage")
    public AjaxResult selectAllCustomerMessage(HttpServletRequest request, @RequestBody CustomerMessage customerMessage){
        Long customerId = loginService.getLoginCustomer(request).getCustomerId();
        customerMessage.setCustomerId(customerId);

        List<CustomerMessage> customerMessages = customerService.selectAllCustomerMessage(customerMessage);
        return AjaxResult.success(customerMessages);
    }

    /**
     * 会员 姓名/手机号查信息
     * */
    @PostMapping("/nameAndPhone")
    public AjaxResult nameAndPhone(@RequestBody Map<String, Object> map){
        String name = null;
        String phone = null;
        if (map.get("name") != null && !map.get("name").equals("")){
            name = map.get("name").toString();
        }
        if (map.get("phone") != null && !map.get("phone").equals("")){
            phone = map.get("phone").toString();
        }

        if (name != null || phone != null) {
            Customer customer;
            try {
                customer = customerService.nameAndPhone(name, phone);
            } catch (Exception e) {
                return AjaxResult.error(e.getMessage());
            }
            if (customer != null) {
                return AjaxResult.success(customer);
            } else {
                return AjaxResult.error("会员信息不正确");
            }
        }
        else {
            return AjaxResult.error("缺少必要参数");
        }
    }

    @PostMapping("/getVipEmployee")
    public AjaxResult getVipEmployee(HttpServletRequest request)
    {
        Long customerId = loginService.getLoginCustomer(request).getCustomerId();
        Employee employee = customerService.getVipEmployee(customerId);
        if (employee != null)
        {
            return AjaxResult.success(employee);
        }
        return AjaxResult.error("没有VIP经理");
    }
}
